<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>商品税号查询</title>
    <jsp:include page="../../head.jsp"/>
    <script type="text/javascript" src="<s:url value="/js/layer/layer.js"/>"></script>
    <script type="text/javascript">
        var formSetting = {
            title: "查询信息",
            module: 'query',
            columns: [
                {
                    name: "gName",
                    label: "商品名",
                }, {
                    name: "codeT",
                    label: "商品编码"
                }, {
                    name: "codeS",
                    label: "商品编码附加码"
                }, {
                    name: "unit1",
                    label: "法定单位"
                }, {
                    name: "ilowPrice",
                    label: "第二单位",
                }, {
                    name: "goodsMode",
                    label: "商品要素"
                }],
            buttons: {
                custom: [{
                    id: "addbtn",
                    value: "新增",
                    click: function () {
                        layer.open({
                                       title: false,
                                       type: 2,
                                       content: "/goods/edit",
                                       area: ['500px', '320px'],
                                       end: function () {
                                           document.getElementById("addbtn").parentNode.firstChild
                                               .click();
                                       }
                                   });
                    }
                }, {
                    id: "editbtn",
                    value: "修改",
                    click: function () {
                        var params = "?";
                        var ids = $('#gridTable').jqGrid('getGridParam', 'selarrrow');
                        if (ids.length == 0) {
                            alert("请选择需要修改的数据");
                            return;
                        }
                        if (ids.length > 1) {
                            alert("一次不能修改多条数据");
                            return;
                        }
                        var rowData = $("#gridTable").jqGrid('getRowData', ids[0]);
                        params += "codeT=" + rowData['codeT'];
                        params += "&codeS=" + rowData['codeS'];
                        layer.open({
                                       title: false,
                                       type: 2,
                                       content: "/goods/edit" + params,
                                       area: ['500px', '320px'],
                                       end: function () {
                                           document.getElementById("editbtn").parentNode.firstChild
                                               .click();
                                       }
                                   });
                    }
                }]
            },
            grid: {
                id: "gridTable",
                title: "查询结果",
                url: "getGoodsCodeList",
                dataType: "application/json",
                multiselect: true,
                colModel: [{
                    index: "G_NAME",
                    name: "gName",
                    label: "商品名",
                }, {
                    index: "CODE_T",
                    name: "codeT",
                    label: "商品编码"
                }, {
                    index: "CODE_S",
                    name: "codeS",
                    label: "商品编码附加码"
                }, {
                    index: "UNIT_1",
                    name: "unit1",
                    label: "法定单位"
                }, {
                    index: "ILOW_PRICE",
                    name: "ilowPrice",
                    label: "第二单位",
                }, {
                    index: "GOODS_MODE",
                    name: "goodsMode",
                    label: "商品要素"
                }]
            }
        };
        $(document).ready(function () {
            $("#table").mrdForm(formSetting);
        });
    </script>
</head>
<body>
<div id="table"></div>
</body>
</html>
